package com.example.admin.goodnews.fragment.DianYingPaiHang;

import android.graphics.Color;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import android.support.v4.view.ViewPager;
import android.support.v4.widget.ListViewAutoScrollHelper;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.example.admin.goodnews.R;
import com.example.admin.goodnews.adapter.FragmentAdapter;

import java.util.ArrayList;
import java.util.List;

/**
 * 电影排行页面
 * Created by admin on 2016/10/13.
 */

public class DianYingPaiHangFragment extends Fragment {
    private ViewPager viewpager_dianyingpaihang;// 加载内容的容器
    private LinearLayout dailyrank;// 日排行榜
    private LinearLayout monthlysales;// 单月票房
    private LinearLayout weekendsales;// 周末票房
    private LinearLayout dailysales;// 单日票房
    private LinearLayout weeklysales;// 单周票房
    private TextView tv_dailyrank, tv_monthlysales, tv_weekendsales, tv_dailysales, tv_weeklysales;
    private TabLayout tablayout_dianyingpaihang;

    private FragmentAdapter fragmentAdapter;
    private List<String> tablists = new ArrayList<>();
    private List<Fragment> fragmentlists = new ArrayList<>();

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View view = LayoutInflater.from(getActivity()).inflate(R.layout.fragment_dianyingpaihang, null);

        viewpager_dianyingpaihang = (ViewPager) view.findViewById(R.id.viewpager_dianyingpaihang);// 加载内容的容器
        tablayout_dianyingpaihang = (TabLayout) view.findViewById(R.id.tablayout_dianyingpaihang);
        initData();
        return view;
    }

    private void initData() {
        tablists.add("日排行榜");
        tablists.add("单月票房");
        tablists.add("周末票房");
        tablists.add("单日票房");
        tablists.add("单周票房");
        fragmentlists.add(new DailyRankFragment());
        fragmentlists.add(new MonthlySalesFragment());
        fragmentlists.add(new WeekendSalesFragment());
        fragmentlists.add(new DailySalesFragment());
        fragmentlists.add(new WeeklySalesFragment());
        fragmentAdapter = new FragmentAdapter(getFragmentManager(), tablists, fragmentlists);
        viewpager_dianyingpaihang.setAdapter(fragmentAdapter);
        tablayout_dianyingpaihang.setupWithViewPager(viewpager_dianyingpaihang);
        viewpager_dianyingpaihang.setCurrentItem(0);
    }

}
